package study.java.thread05;

/**
* @Name: DieLockRunnable
* @Description: 死锁问题多线程测试类
* @Author: 李超	lc_jack@foxmail.com
* @CreateDate: 2017-1-9 下午4:29:46 
* @Version: V1.0
 */
public class DieLockThread extends Thread {
	
	private boolean flag ;
	
	public DieLockThread() {
	}
	public DieLockThread(boolean flag) {
		this.flag = flag;
	}

	@Override
	public void run() {
		if(flag) {
			synchronized (MyLock.lockA) {
				System.out.println("if lockA");
				synchronized (MyLock.lockB) {
					System.out.println("if lockB");
				}
			}
		} else {
			synchronized (MyLock.lockB) {
				System.out.println("else lockB");
				synchronized (MyLock.lockA) {
					System.out.println("else lockA");
				}
			}
		}
	}

}
